Visibility of updates in MarkLogic transactions
I’m a bit ashamed to admit that even after being a MarkLogic developer for a year and a half, I still make mistakes like this:
This query will always return “NO” because any updates made in a transaction will not be visible until after the updating statement is completed.
For a query like the short example above, it will be executed as a single-statement transaction so the update (in this case, the result of the xdmp:document-insert() function) isn’t visible until the transaction is committed. In multi-statement transactions, the update will be visible in subsequent statements in the same transaction.
More information can be found in the MarkLogic documentation: http://docs.marklogic.com/guide/app-dev/transactions#id_85012
Roxy Framework app-type
The Roxy Framework for MarkLogic lets you choose between one of three app-types when you first instantiate the application:
- mvc: a normal, XQuery-based Roxy MVC app
- rest: an app based on the ML REST API
- hybrid: an app that uses Roxy rewriting and the ML REST API
This can be a confusing choice but after a few months of using Roxy for a number of different use cases, I’ve come to the conclusion that most people will want to choose either the ‘mvc’ or ‘hybrid’ app-type.
Which one should you choose?
If you know with absolute certainty that your application will be written in XQuery, you want to leverage the Roxy MVC framework and will not be using the MarkLogic REST API at all, then ‘mvc’ is the clear choice. This is the traditional MarkLogic application development model that many experienced MarkLogic developers prefer over the new REST and Java APIs.
If you think you’ll be using the ML REST or Java API, whether it is from a front-end application also hosted from the MarkLogic HTTP application server or a separate Java/Ruby/Python/.NET application server, you should choose the ‘hybrid’ app type.
What is the difference between the ‘hybrid’ and ‘rest’ app type? The primary difference is the URL rewriter that’s used to route requests to the application server. The ‘rest’ app type configures the URL rewriter to be the default MarkLogic REST API rewriter which only really knows how to handle requests to the known REST API endpoints. The ‘hybrid’ app type configures the URL rewriter to be the Roxy rewriter which by default, knows how to route requests to the MarkLogic REST API endpoints but also lets you add additional routes so you can host additional endpoints from the same app server instance.
Why would you want to host additional endpoints from the same app server instance? You may want to develop custom endpoints that perform application-specific logic which would otherwise require multiple queries if you solely relied on the out of the box ML REST API. Yes, the MarkLogic REST API does provide an extension mechanism to support custom endpoints but I’ve found that utilizing the Roxy rewriter’s ability to route REST API and custom endpoint requests to be a better/cleaner/more flexible way to provide custom services.
In summary, my recommendations are:
1) If you are writing an XQuery application with absolutely no intention of using the REST API, choose the ‘mvc’ app-type.
2) Otherwise, choose the ‘hybrid’ app-type and consider writing custom endpoints as Roxy application endpoints instead of REST API extensions.
Update (11/6/2013): My colleague Dave Cassel brought up a good point with me that the MarkLogic Java API provides a mechanism to call REST API extensions in the API itself: http://docs.marklogic.com/guide/java/resourceservices#chapter. However, if we’re assuming we’re working in a Java context anyways, it’s also worth considering the fact that many modern Java application frameworks provide helper utilities and constructs for calling RESTful web services. For example, Spring provides a RestTemplate as documented here: http://spring.io/guides/gs/consuming-rest/. Play Framework provides the play.libs.WS library as documented here: http://www.playframework.com/documentation/2.2.x/JavaWS. While it’s nice that ML REST API extensions can be exposed through the ML Java API itself, it’s clear that implementing this custom logic via Roxy endpoints would not introduce much more complexity or additional work.
Marketing church to a specific demographic
Perhaps we don’t like to think that churches target their services and programs to a specific demographic or preference, but regardless of whether they are intentional about it or not, it happens.
If you look at the wide variety of news magazines available on a typical newsstand, each of them appeal to a different subset of the population. Some of those subsets overlap, some don’t. For example, magazines like Newsweek and Time probably aim for the broadest swath of the reading public. As a result, they design their magazines and publish content that tries to appeal to as many people as possible — they tend to include larger and more images and target a lower reading comprehension level than other magazines. However, other news magazines such as The Economist and The Atlantic make an intentional appeal for a more educated and wealthier target audience. The stories are a bit more in-depth and are written at a higher reading comprehension level. You can just tell from comparing the advertisements between Time and The Economist who they think their readers are.
What does this have to do with church? A major part of any church’s mission is to communicate a message and it’s important to recognize that how the message is communicated influences the type of people who will be drawn to your message and to your church. A church has to decide whether their sermons are going to consist of content that’s more like Time, The Economist, People, or Sports Illustrated — none of those “styles” would be bad but a church should be honest with what demographic of people they are primarily targeting and deliver a relevant message. It would be dishonest to say that you want your church to be open to people from all educational and cultural backgrounds while preaching sermons that feel like they come out of The Economist. A church would also have to realize that delivering sermons at the level of Time magazine would turn off people who want an Economist-level message.
While some people are disheartened by what they perceive to be “division” in the church by seeing so many different kinds on churches out there, I see this as a positive development in the church as a whole. We live in a society that is more and more stratified by race, wealth, culture, etc., and while we long for the day when people from all backgrounds will worship God as one, our humanness requires that we communicate Jesus in a way that is receptive to the wide variety of levels in which people communicate today. I think churches should also be more open to offering services and programs that target different groups — for example having a single church offer a 9am liturgical service, 11am rock-music-style service, a 5pm academic/lecture-style service, and a 7pm experiential prayer service. How awesome would that be?
Challenging yourself to remain open-minded
Today is my birthday and I am now 35 years old. I can no longer honestly say I’m in my early 30s anymore. :( People in their 20s are still largely considered “young” by most standards — most people in their 20s haven’t gotten married and don’t have kids yet. If the age of 30 isn’t that tipping point between being “young” vs “old”, then the age of 35 is clearly on the “old” side, at least from my narrow perspective. :)
I’ve been married for almost a decade (!!!), have two young kids, and my hairline is starting to recede. I’m getting old. One way I need to continue challenging myself as I get older is to remain open-minded and be willing to try new things, consider new ideas, etc.
Many people I know get stubborn and close-minded as they get older. I don’t know if human beings are just wired to be that way. Even if we are wired to become more set in our ways as we age, I believe we need to force ourselves to be comfortable with change and new ideas if we want to remain marketable.
This may seem to go against common sense. We often spend significant amounts of time, money and energy investing in people, places, skills, etc. which become increasingly difficult to give up over time precisely because we’ve made such a huge investment in those things. However, I believe nothing forces people to grow as individuals more than intentionally (or unintentionally) imposing change upon our lives. I believe change is good.
- Changing where you live forces you to open yourself up to new people/relationships.
- Changing where you work forces you to learn how to be productive with a new group of colleagues, learn new skills, etc.
I hope people around me can continue encouraging me to pursue new experiences.
Warby Parkers are not for people with strong prescriptions
I got my Warby Parkers and unfortunately I’ll be returning them. For normal eyeglasses, they only offer high-index lenses at 1.67. For sunglasses, they don’t offer high-index lenses at all. I asked them about both — they said their business model is based on keeping things simple, which necessarily excludes serving the needs of a subset of their potential customer base.
I decided to try ordering them anyways since they have a 30-day money back guarantee. It turns out that even the 1.67 high-index lenses are too thick for my prescription. The thickness really affects the way the eyeglasses look, not just from the side but also from the front. Most conventional opticians offer a 1.74 high-index lens (which is what I have in my current eyeglasses) and they’re great. Bottom line is that if your prescription is worse than about -6 (mine is around -8), I wouldn’t bother with getting Warby Parkers.
I wish Warby Parker would advise customers against ordering prescription glasses from them if the prescription is fairly strong but I guess there are cost-conscious customers out there who may not mind the thick lenses. Prescription eyeglasses with the high-index lenses will cost about $175 from Warby Parker (included frames and lenses), which is a great deal. If I didn’t have vision insurance, my current eyeglasses with ProDesign frames + 1.74 high-index lenses would probably cost around $500-600. I hope Warby Parker offers the 1.74 high-index lenses some day — even if they had to add a $150 surcharge for the super high-index, they’d still be a great deal.
P1070902 on Flickr.
Hundreds, if not thousands of Hoboken families starting to walk down Washington Street for the Halloween parade. Hoboken’s days of being known for drunk 20-somethings is over.
Young people from less-privileged homes are more likely to graduate from college and earn more if raised by two married parents.
Yet another article about how important it is for children to grow up in a stable, two-parent family, *especially* when the family is less privileged. Yes, it’s important to not ostracize single parents but we have to be careful that in our support of single parents, we don’t hide the fact that there are negative consequences to single parenthood. There is clearly an advantage for kids whose parents stay married.
System76 manufactures high quality Ubuntu laptops, desktops, and servers - paired with industry leading support and customer service.
I was thinking that if I couldn’t get a Mac laptop for my work computer, I’d much prefer running Linux instead of Windows. As a software engineer, I have very little need for most of the commercial software packages. When I was a consultant at my previous job, I was more dependent on Microsoft Office, but currently, all I need are IntelliJ (which is available for Linux), a decent web browser, and a *real* command line. I’m not necessarily anti-Microsoft (I actually like Windows Phone and Windows 8) but I can’t stand not having a real command line when using Windows (and no, Cygwin doesn’t count).
For my home computer, I do quite a bit of photo editing for which I’d want to use Apple Aperture or Adobe Lightroom which aren’t available for Linux, so I have to go with a Mac there.
The laptops from System76 look pretty sweet. I also appreciate that they don’t charge a huge premium for the configurable options. Apple charges $100 for going from 4GB to 8GB and $300 for 4GB to 16GB! System76 only charges $65 and $175 for the equivalent. System76 also offers a lot more choices for your hard drive.
Python and XQuery: constructing lists/sequences functionally
When you learn XQuery, if you come from programming background in languages like Java or C#, it can be annoying finding out that you can’t do something simple like this:
XQuery is a functional programming language, so variables are immutable. You can’t initialize an empty data structure, then append to it. So the proper way to build this “array” is to include whatever logic you want to apply in the construction process. e.g.
After a few months or years of primarily writing code in XQuery, when you go back to Java (or any other language), you will be surprised when you find yourself wanting to code using XQuery-ish syntax. Fortunately, some languages, like Python, support functional programming constructs. Python has this concept of list comprehension where you can construct lists in a similar fashion as XQuery:
A few days ago one of my daughters asked me, “Mom, what do you think you’re best at?”I paused before answering, “Well, I think I’m really good at hiring really smart
I was just thinking about this a few days ago and about to write a blog post about it but Michelle Rhee summed it up pretty well: “I always say that if I’m the smartest person in the room, we’re in trouble.”
Instead of worrying about your ego/status/title, the best thing you can do is surround yourself with really smart and talented people you can learn from; this will only make you better.